package cn.zcscloud.mall.mbg.mapper;

import cn.zcscloud.mall.mbg.model.PmsProduct;
import cn.zcscloud.mall.mbg.model.PmsProductExample;
import java.util.List;

import cn.zcscloud.mall.vo.PmsProductResult;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface PmsProductMapper extends BaseMapper<PmsProduct> {
    @Select("SELECT\n" +
            "\t*,\n" +
            "\tpc.parent_id cateParentId,\n" +
            "\tl.id ladder_id,\n" +
            "\tl.product_id ladder_product_id,\n" +
            "\tl.discount ladder_discount,\n" +
            "\tl.count ladder_count,\n" +
            "\tl.price ladder_price,\n" +
            "\tpf.id full_id,\n" +
            "\tpf.product_id full_product_id,\n" +
            "\tpf.full_price full_full_price,\n" +
            "\tpf.reduce_price full_reduce_price,\n" +
            "\tm.id member_id,\n" +
            "\tm.product_id member_product_id,\n" +
            "\tm.member_level_id member_member_level_id,\n" +
            "\tm.member_price member_member_price,\n" +
            "\tm.member_level_name member_member_level_name,\n" +
            "\ts.id sku_id,\n" +
            "\ts.product_id sku_product_id,\n" +
            "\ts.price sku_price,\n" +
            "\ts.low_stock sku_low_stock,\n" +
            "\ts.pic sku_pic,\n" +
            "\ts.sale sku_sale,\n" +
            "\ts.sku_code sku_sku_code,\n" +
            "\ts.stock sku_stock,\n" +
            "\ts.sp_data sku_sp_data,\n" +
            "\ta.id attribute_id,\n" +
            "\ta.product_id attribute_product_id,\n" +
            "\ta.product_attribute_id attribute_product_attribute_id,\n" +
            "\ta.\n" +
            "VALUE\n" +
            "\tattribute_value \n" +
            "FROM\n" +
            "\tpms_product p\n" +
            "\tLEFT JOIN pms_product_category pc ON pc.id = p.product_category_id\n" +
            "\tLEFT JOIN pms_product_ladder l ON p.id = l.product_id\n" +
            "\tLEFT JOIN pms_product_full_reduction pf ON pf.product_id = p.id\n" +
            "\tLEFT JOIN pms_member_price m ON m.product_id = p.id\n" +
            "\tLEFT JOIN pms_sku_stock s ON s.product_id = p.id\n" +
            "\tLEFT JOIN pms_product_attribute_value a ON a.product_id = p.id \n" +
            "WHERE\n" +
            "\tp.id = #{id};")
    PmsProductResult seleteById(Long id);
}